package gui_kalenderpanel;
import java.awt.Color;
import model.*;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;


public class DeltagerRenderer extends DefaultListCellRenderer implements ListCellRenderer{
	
	public Component getListCellRendererComponent(final JList list, Object value,
			final int index, boolean isSelected, boolean cellHasFocus) {
		
		JPanel deltPane = new JPanel();
		Deltager curr = (Deltager) value;
		String navn = curr.getNavn();
		JLabel navnLab = new JLabel(navn);
		
		Status stat = curr.getStatus();
		if (stat == Status.godtatt) {
			deltPane.setBackground(Color.GREEN);
		}
		else if (stat == Status.forkastet) {
			deltPane.setBackground(Color.RED);
		}
		else {
			deltPane.setBackground(Color.YELLOW);
		}
		
		if (list.isSelectedIndex(index)) {
			deltPane.setBackground(Color.BLUE);
		}
		
		deltPane.add(navnLab);
		
		
		return deltPane;
		
	}

}
